/*
 * UserService.java
 *
 * Copyright 2012 the original author or authors(ninglong).
 *
 * Licensed under the web-geek, Version 1.0 (the "License");
 *
 */
package org.geek.user.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.geek.common.entity.Criteria;
import org.geek.domain.User;
import org.geek.user.mapper.UserMapper;
import org.geek.user.service.IUserService;
import org.springframework.stereotype.Service;

/**   
 * <p>用户服务类</p>
 * @author ninglong bhd2973@qq.com   
 * @version V1.0   
 */
@Service
public class UserService implements IUserService {
	
	@Resource
	private UserMapper userMapper;

	@Override
	public User getUserByAccount(String account) {
		return userMapper.getUserByAccount(account);
	}

	@Override
	public List<User> getUserByCriteria(Criteria criteria) {
		return userMapper.getUserByCriteria(criteria);
	}

	@Override
	public int countUserByCriteria(Criteria criteria) {
		return userMapper.countUserByCriteria(criteria);
	}

	@Override
	public int addUser(User user) {
		return userMapper.addUser(user);
	}
	@Override
	public int modUser(User user) {
		return userMapper.modUser(user);
	}

	@Override
	public int delUserByUserId(int userId) {
		int i = userMapper.delUserByUserId(userId);
		i = i + userMapper.delUserAndRoleByUserId(userId);//删除用户后，将t_user_role表与该用户有关的数据删除
		return i;
	}
}
